<?php 
	class GalleryModel extends Model {
		public function __construct(){
			$this->open(Model::MYSQL);
			$this->calledClass(get_class($this));
		}
		public function savephoto($fields){
			$this->open(MODEL::MYSQL);
			return parent::save($fields);
		}
		public function deletephoto($ids=array(),$deleteFile=false){
			if($records=parent::delete($ids,true)){
				if($deleteFile){
					foreach($records as $record){
						Basic::fileExist(REAL_PATH.$record->location)?unlink(REAL_PATH.$record->location):false;
					}
				}
				return true;
			}
			return false;
		}
		public function getList($page=1,$perpage=20,$search="",$searchColumns = array() , $sortColumn = array() , $sortCriteria = "ASC" ){
			return parent::getList($page,$perpage,$search,$searchColumns, $sortColumn, $sortCriteria);
		}
		public function update($fields=array(),$where=array()){
			return parent::update($fields,$where);
		}
		public function Gallery($can_id){
			$query="SELECT location FROM Galleries WHERE uid=$can_id";
			return parent::query($query);
		}
		public function findRecord($can_id,$user_type){
			$query="SELECT Galleries.location FROM Galleries WHERE uid=$can_id  AND user_type='$user_type'";
			$result= parent::query($query);
			while($row=mysql_fetch_object($result))$record[]=$row;
			return @$record;
		}
		public function findObject($where=array()){
			return parent::findAsObject($where);
		}
	}